package hn.sigit.model.hnd.administrative;

import hn.sigit.model.ladm.external.ExtParty;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="HND_NaturalPersonParty", schema="hnd_administrative")
@Inheritance(strategy=InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name="ExtPartyID")
public class HND_NaturalPersonExtParty extends ExtParty implements Serializable, Cloneable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public HND_NaturalPersonExtParty() {
	}

	private String firstName1;
	private String firstName2;
	private String lastName1;
	private String lastName2;
	private char gender;
	private String nationality;
	private java.util.Date dob;
	private char maritalStatus;
	private String identity;
	private String rtn;
	private hn.sigit.model.hnd.administrative.HND_User sigitUser;

	
	@Column(name="FirstName1", nullable=true, length=255)
	public String getFirstName1() {
		return firstName1;
	}
	public void setFirstName1(String value) {
		this.firstName1 = value;
	}
	
	@Column(name="FirstName2", nullable=true, length=255)
	public String getFirstName2() {
		return firstName2;
	}
	public void setFirstName2(String value) {
		this.firstName2 = value;
	}
	
	@Column(name="LastName1", nullable=true, length=255)
	public String getLastName1() {
		return lastName1;
	}
	public void setLastName1(String value) {
		this.lastName1 = value;
	}
	
	@Column(name="LastName2", nullable=true, length=255)
	public String getLastName2() {
		return lastName2;
	}
	public void setLastName2(String value) {
		this.lastName2 = value;
	}
	
	@Column(name="Gender", nullable=false, length=1)
	public char getGender() {
		return gender;
	}
	public void setGender(char value) {
		this.gender = value;
	}
	
	@Column(name="Nationality", nullable=true, length=255)
	public String getNationality() {
		return nationality;
	}
	public void setNationality(String value) {
		this.nationality = value;
	}
	
	@Column(name="Dob", nullable=true)
	public java.util.Date getDob() {
		return dob;
	}
	public void setDob(java.util.Date value) {
		this.dob = value;
	}
	
	@Column(name="MaritalStatus", nullable=false, length=1)
	public char getMaritalStatus() {
		return maritalStatus;
	}
	public void setMaritalStatus(char value) {
		this.maritalStatus = value;
	}
	
	@Column(name="Identity", nullable=true, length=255)
	public String getIdentity() {
		return identity;
	}
	public void setIdentity(String value) {
		this.identity = value;
	}
	
	@Column(name="Rtn", nullable=true, length=255)
	public String getRtn() {
		return rtn;
	}
	public void setRtn(String value) {
		this.rtn = value;
	}
	
	@OneToOne(targetEntity=hn.sigit.model.hnd.administrative.HND_User.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="HND_UserID") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public hn.sigit.model.hnd.administrative.HND_User getSigitUser() {
		return sigitUser;
	}
	public void setSigitUser(hn.sigit.model.hnd.administrative.HND_User sigitUser) {
		this.sigitUser = sigitUser;
	}
	
	
	@Transient
	public String getFullNameLastNameFirst() {
		StringBuffer sb = new StringBuffer();
		sb.append(lastName1);
		if (lastName2 != null) sb.append(" " + lastName2);
		sb.append(", " + firstName1);
		if (firstName2 != null) sb.append(firstName2);
		
		return sb.toString();
	}
	
	public String toString() {
		return super.toString();
	}
	
	@Transient
	@Override
	public String getName() {
		// TODO Auto-generated method stub
		StringBuffer sb = new StringBuffer();
		sb.append(firstName1);
		if (firstName2 != null) sb.append(" " + firstName2);
		if (lastName1 != null) sb.append(" " + lastName1);
		if (lastName2 != null) sb.append(" " + lastName2);
		
		return sb.toString();
	}
	
	@Override
	public HND_NaturalPersonExtParty clone() {
		try {
			return (HND_NaturalPersonExtParty)super.clone();
		} catch (CloneNotSupportedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
}
